<?php

namespace Common\Model;

/**
 * AuthorityAccessModel.class实例模型
 * 
 * @author songanwei
 * @date 2016-1-11
 */
class AuthorityAccessModel extends BaseModel {

    protected $trueTableName = 'tb_authority_access';

    /**
     * 根据访问方法返回权限数据
     * @modify songanwei 2016-01-11
     * @param string $action 访问方法
     * @return type
     */
    public function getInfoByAction($action) {
        return $this->where(array('action' => $action))->find();
    }

    /**
     * 根据权限id返回进入的控制方法
     * @modify songanwei 2016-01-27
     * @param array|string $hotelAuthorityId
     * @return type
     */
    public function getAccessByAuthorityId($hotelAuthorityId) {
        if (is_array($hotelAuthorityId)) {
            $hotelAuthorityId = implode(',', $hotelAuthorityId);
        }
        if (strpos($hotelAuthorityId, ',') !== false) {
            $option['hotelauthority_id'] = array('in', $hotelAuthorityId);
        } else {
            $option['hotelauthority_id'] = $hotelAuthorityId;
        }
        return $this->where($option)->select();
    }

}
